<template>
	<view>
		<u-button @click="tocode">扫码</u-button>
		<u-input v-model="code" :disabled="true"></u-input>
		<u-cell-group v-show="Goods.Name">
			<u-cell title="UID" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.Id}}</span>
			</u-cell>
			<u-cell title="厂家" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.Factory || " "}}</span>
			</u-cell>
			<u-cell title="状态" :use-label-slot="true">
				<span slot="label" class="cell-label">{{Goods.Status || " "}}</span>
			</u-cell>
			<u-cell title="品名" :use-label-slot="true">
				<span slot="label" class="cell-label">{{Goods.Name || " "}}</span>
			</u-cell>
			<u-cell title="标签" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.Tag || " "}}</span>
			</u-cell>
			<u-cell title="品牌" :use-label-slot="true">
				<span slot="label" class="cell-label">{{Goods.brand || " "}}</span>
			</u-cell>
			<u-cell title="存放位置" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.Position || " "}}</span>
			</u-cell>
			<u-cell title="型号" :use-label-slot="true">
				<span slot="label" class="cell-label">{{Goods.Model || " "}}</span>
			</u-cell>
			<u-cell title="所属公司" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.Dept.Name || " "}}</span>
			</u-cell>
			<u-cell title="单位" :use-label-slot="true">
				<span slot="label" class="cell-label">{{Goods.Unit || " "}}</span>
			</u-cell>
			<u-cell title="生产厂家" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.Factory || " "}}</span>
			</u-cell>
			<u-cell title="二维码" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.QRcode || " "}}</span>
			</u-cell>
			<u-cell title="备注" :use-label-slot="true">
				<span slot="label" class="cell-label">{{formInfo.Remark|| " "}}</span>
			</u-cell>
		</u-cell-group>
	</view>
</template>

<script>
	import {
		baseUrl
	} from '@/common/config.js'
	import {
		scancode,
		getequ
	} from '@/common/api.js'
	export default {
		data() {
			return {
				code: "",
				Goods: {},
				formInfo: {}
			}
		},
		onLoad() {
			this.user = JSON.parse(uni.getStorageSync("$userinfo"))

		},
		onShow() {
			// this.code = uni.getStorageSync("$scancode")
			setTimeout(() => {
				this.code = uni.getStorageSync("$scancode")
				let para = {
					Parameters: [{
						FieldName: "Code",
						ConditionalType: "equal",
						FieldValue: uni.getStorageSync("$scancode")
					}]
				}
				getequ(para).then(res => {
					console.log(res);
					if (res.count != 0) {
						this.formInfo = res.data[0]
						this.Goods = res.data[0].StoreGoods
					} else {
						this.formInfo = {}
						this.Goods = {}
					}
				})
			}, 2000)
		},
		onReady() {

		},
		methods: {
			tocode() {
				wx.scanCode({
					success(res) {
						scancode(res.result).then(res1 => {
							this.code = res1
							uni.setStorageSync("$scancode", res1)
						})
					},
					fail(res) {
						console.log(res);
					}
				})
			},
		}
	}
</script>

<style>

</style>